﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;

namespace LinkShareWpf.Converters
{
    public class PingToColorBrushConverter : IValueConverter
    {
         #region IValueConverter Members

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        long ping = long.Parse(value.ToString());
        SolidColorBrush brush = null;
        if (ping >=0 && ping <= 20)
            brush = new SolidColorBrush(Colors.LightGreen);
        else
            if (ping >= 20 && ping <=79)
                brush = new SolidColorBrush(Colors.Yellow);
            else
                if (ping >= 80)
                    brush = new SolidColorBrush(Colors.Red);
                else
                    brush = new SolidColorBrush(Colors.Black);
        return brush;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }

    #endregion
  }
}






